package com.ljsw.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ljsw.activity.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 我的任务 开始扫描  适配器
 * 作者: 石锚
 * 版本: 1.0
 * 日期: 2015-10-12
 */
public class PKReconciDialogadapter extends BaseAdapter{
	private Context context;
	private List<String> list = new ArrayList<String>();

	public PKReconciDialogadapter(Context context, List<String> list) {
		super();
		this.context = context;
		this.list = list;
	}

//	public PKReconciDialogadapter(Context context) {
//		super();
//		this.context = context;
//		load();
//	}
	
	public void upListView(ArrayList<String> ll){
		this.list = ll;
		this.notifyDataSetChanged();
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if(arg1==null){
			holder = new ViewHolder();
			arg1 = LayoutInflater.from(context).inflate(R.layout.saomiao_list_item, null);
			holder.cardId = (TextView) arg1.findViewById(R.id.cardtext);
			arg1.setTag(holder);
		}else{
			holder = (ViewHolder) arg1.getTag();
		}
		holder.cardId.setText(list.get(arg0));
		return arg1;
	}
	
	static class ViewHolder{
		private TextView cardId;
	}
	/**
	 * 初始化数据
	 */
	public void load(){
		list.add("HS0000001");
		list.add("HS0000002");
		list.add("HS0000003");
		list.add("HS0000004");
		list.add("HS0000005");
	}
}
